<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body></body>

</html>
<script>
  // 这个是Array数组测试用例👇
  var array = [1, 1, '1', '1', null, null,

  undefined, undefined,
                  new String('1'), new String('1'),
                  /a/, /a/,
                  NaN, NaN

  ];

  // 使用Set
  var array = [1, 1, "1", "1", null, null];
  let unique_1 = (arr) => [...new Set(arr)];

  // 使用filter
  function unique_2(array) {
    var res = array.filter(function (item, index, array) {
      return array.indexOf(item) === index;
    });
    return res;
  }

  // 使用reduce

  let unique_3 = (arr) =>
    arr.reduce((pre, cur) => (pre.includes(cur) ? pre : [...pre, cur]), []);
</script>